// 位置信息接口
export interface ILocation {
  ip: string
  location: {
    lat: number
    lng: number
  }
  ad_info: {
    nation: string
    province: string
    city: string
    district: string
    adcode: number
    nation_code: number
  }
}

// 天气信息接口
export interface IWeather {
  code: string
  updateTime: string
  fxLink: string
  now: {
    obsTime: string
    temp: string
    feelsLike: string
    icon: string
    text: string
    wind360: string
    windDir: string
    windScale: string
    windSpeed: string
    humidity: string
    precip: string
    pressure: string
    vis: string
    cloud: string
    dew: string
  }
  refer: {
    sources: string[]
    license: string[]
  }
}

// 和风天气位置信息接口
export interface IHFLocation {
  id: string
  name: string
  country: string
  adm1: string
  adm2: string
  lat: string
  lon: string
  tz: string
  utcOffset: string
  isDst: string
  type: string
  rank: string
  fxLink: string
}

// 位置数据接口
export interface ILocationData {
  id: string
  name: string
  country: string
  adm1: string
  adm2: string
  lat: number
  lon: number
  weather: IWeather | null
  isDefault: boolean
  isCurrent: boolean
  airQuality: IAirQuality | null
  indices: WeatherIndices | null
  future: IWeatherFuture | null
  HourlyWeather: IHourlyWeather | null
  warningData: IWarning | null
}

// 天气状态接口
export interface IWeatherState {
  locations: Map<string, ILocationData>
  currentLocationId: string | null
  defaultLocationId: string | null
  isLoading: boolean
  error: string | null
}
// 定义城市数据接口
export interface ICityData {
  name: string // 城市名称
  id: string // 城市ID
  lat: string // 纬度
  lon: string // 经度
  adm2: string // 二级行政区域（区县）
  adm1: string // 一级行政区域（省市）
  country: string // 国家
  tz: string // 时区
  utcOffset: string // UTC偏移量
  isDst: string // 是否夏令时
  type: string // 类型
  rank: string // 等级
  fxLink: string // 天气链接
}
export interface IAirQuality {
  metadata: {
    tag: string
  }
  indexes: {
    code: string
    name: string
    aqi: number
    aqiDisplay: string
    level: string
    category: string
    color: {
      red: number
      green: number
      blue: number
      alpha: number
    }
    primaryPollutant: {
      code: string
      name: string
      fullName: string
    }
    health: {
      effect: string
      advice: {
        generalPopulation: string
        sensitivePopulation: string
      }
    }
  }[]
  pollutants: Array<{
    code: string
    name: string
    fullName: string
    concentration: {
      value: number
      unit: string
    }
    subIndexes: Array<{
      code: string
      aqi: number
      aqiDisplay: string
    }>
  }>
  stations: Array<{
    id: string
    name: string
  }>
}

// 定义位置信息接口
export interface LocationResult {
  ip: string
  location: {
    lat: number
    lng: number
  }
  ad_info: {
    nation: string
    province: string
    city: string
    district: string
    adcode: number
    nation_code: number
  }
}
// 定位接口返回数据
export interface LocationResponse {
  data: {
    status: number
    message: string
    request_id: string
    result: LocationResult
  }
}
// 天气指数类型枚举
export enum weatherIncludesType {
  'ALL', //全部天气指数
  'SPT', //运动指数
  'CW', //洗车指数
  'DRSG', //穿衣指数
  'FIS', //钓鱼指数
  'UV', //紫外线指数
  'TRA', //旅游指数
  'AG', //花粉过敏指数
  'COMF', //舒适度指数
  'FLU', //感冒指数
  'AP', //空气污染扩散条件指数
  'AC', //空调开启指数
  'GL', //太阳镜指数
  'MU', //化妆指数
  'DC', //晾晒指数
  'PTFC', //交通指数
  'SPI', //防晒指数
}

export enum weatherIncludes_CN {
  '全部天气指数',
  '运动指数',
  '洗车指数',
  '穿衣指数',
  '钓鱼指数',
  '紫外线指数',
  '旅游指数',
  '花粉过敏指数',
  '舒适度指数',
  '感冒指数',
  '空气污染扩散条件指数',
  '空调开启指数',
  '太阳镜指数',
  '化妆指数',
  '晾晒指数',
  '交通指数',
  '防晒指数',
}
// 天气指数接口
export interface WeatherIndices {
  code: string
  updateTime: string
  fxLink: string
  daily: Daily[]
  refer: Refer
}

export interface Daily {
  date: Date
  type: string
  name: string
  level: string
  category: string
  text: string
}

interface Refer {
  sources: string[]
  license: string[]
}

// 未来天气接口
export interface IWeatherFuture {
  code: string
  updateTime: string
  fxLink: string
  daily: DailyFuture[]
  refer: Refer
}

export interface DailyFuture {
  fxDate: string
  sunrise: string
  sunset: string
  moonrise: string
  moonset: string
  moonPhase: string
  moonPhaseIcon: string
  tempMax: string
  tempMin: string
  iconDay: string
  textDay: string
  iconNight: string
  textNight: string
  wind360Day: string
  windDirDay: string
  windScaleDay: string
  windSpeedDay: string
  wind360Night: string
  windDirNight: string
  windScaleNight: string
  windSpeedNight: string
  humidity: string
  precip: string
  pressure: string
  vis: string
  cloud: string
  uvIndex: string
}
// 小时接口

export interface IHourlyWeather {
  code: string
  updateTime: string
  fxLink: string
  hourly: Hourly[]
  refer: Refer
}
export interface Hourly {
  fxTime: string
  temp: string
  icon: string
  text: string
  wind360: string
  windDir: string
  windScale: string
  windSpeed: string
  humidity: string
  pop: string
  precip: string
  pressure: string
  cloud: string
  dew: string
}
// 预警接口
export interface IWarning {
  code: string
  updateTime: string
  fxLink: string
  warning: WarningType[]
  refer: Refer
}

export interface WarningType {
  id: string
  sender: string
  pubTime: string
  title: string
  startTime: string
  endTime: string
  status: string
  level: string
  severity: string
  severityColor: string
  type: string
  typeName: string
  urgency: string
  certainty: string
  text: string
  related: string
}
